﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class AlonepageModel extends BaseModel
{

    var $table  = 'alonepage';	

    var $_page_rows = 20;	
	
    /* 插入数据 */
    function post($data)
    {    
	
		$time = time();     
    
		return $this->IU_Sql_Exe(array ('data' => array('user_id'=>"$data[user_id]",'cat_id'=>"$data[cat_id]",'name'=>"$data[name]",'title'=>"$data[title]",'filename'=>"$data[filename]",'filepath'=>"$data[filepath]",'keywords'=>"$data[keywords]",'description'=>"$data[description]",'content'=>"$data[content]",'picurl'=>"$data[picurl]",'modue'=>"$data[modue]",'add_time'=>"$time",'lang_type'=>trim($GLOBALS['Lang']->_lang_tp)), 'mode' => 'INSERT'));

        
    }

    function show()
    {   
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>"lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' ",'url' => 'admin/?app=alonepage&act=index'));		
		 $info['data'] = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' ",'order' =>'add_time desc','limit' =>$info['page']['sql_limit']));
    
		 return $info;
        
    }


    /* 删除数据 */
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editaction($id ='',$data = '')
    {    
		$time = time();  	      
		return $this->IU_Sql_Exe(array ('data' => array('user_id'=>"$data[user_id]",'cat_id'=>"$data[cat_id]",'name'=>"$data[name]",'title'=>"$data[title]",'filename'=>"$data[filename]",'filepath'=>"$data[filepath]",'keywords'=>"$data[keywords]",'description'=>"$data[description]",'content'=>"$data[content]",'picurl'=>"$data[picurl]",'modue'=>"$data[modue]",'add_time'=>"$time",'lang_type'=>trim($GLOBALS['Lang']->_lang_tp)),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));
        
    }

    /* 修改数据 */
    function editpicurl($id ='',$data = '')
    {   
     
		return $this->IU_Sql_Exe(array ('data' => array('picurl'=>"$data[picurl]"),'mode' => 'UPDATE','id' =>"id = '{$id}' "));
        
    }

    /* 通过id取出一条数据 */
    function oneshow($id ='')
    {    
	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));
    
		 return $info;
        
    }


}




?>